<?php
	include("API.php");
	session_start();
	if (isset($_POST["logout"])) 
	{
		if ($_POST["logout"] == 0) 
		{
			$sessionid = login($client,$_POST["mail"],$_POST["password"]);
			if ($sessionid) 
			{
				$_SESSION["sessionid"] = $sessionid;
				$_SESSION["mail"] = $_POST["mail"];
			}
		}
		else 
		{
			logout($client,$_SESSION["sessionid"]);
			session_destroy();
			echo '<meta http-equiv="refresh" content="0;URL=head.php"></meta>';
		}
	}
?>

<html>
<head><meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<TABLE cellpadding="5" align = "right">
<TR>
<TD valign="center" style="font-family:verdana;font-size:140%" ><I>Netbook.</I> </TD>
<?php
$a='"';
$b="'";
if (isset($_SESSION["sessionid"])){
	echo "<form  action = ".$a."head.php".$a." method = ".$a."post".$a.">";
	echo '<input type="hidden" name="logout" value="1"/>';
	echo '<td><input type="submit" value="注销"/></td>';
	echo '</form>';
}
else {
	echo "<form  action = ".$a."head.php".$a." method = ".$a."post".$a.">";
	echo '<td>邮箱：<input type="text" name="mail" /> </td>';
	echo '<td>密码：<input type="password" name="password" /> </td>';
	echo '<input type="hidden" name="logout" value="0"/>';
	echo '<td><input type="submit" value="登陆"/></td>';
	echo '</form>';
	echo '<TD valign="center"><INPUT TYPE="button" VALUE="注册" ONCLICK="window.top.location="reg.php"; "></TD>';
}
?>
</TR>
<TR>

</TR>
</TABLE>


</body>
</html
